#ifndef _PERIPHERAL_RECEIVE_TASK_H_
#define _PERIPHERAL_RECEIVE_TASK_H_

/*遥操作接收数据来源事件组BIT宏定义*/
#define EVENT_GROUP_BIT_ERROR 			(1UL << 0UL)	//传输错误,一段时间内都未接收到正确信号
#define EVENT_GROUP_BIT_DT7 			(1UL << 1UL)	//DT7遥控器

#define UART1_MAX_RECEIVE_BUFFER_LENGTH 50
#define UART3_MAX_RECEIVE_BUFFER_LENGTH 50
#define UART6_MAX_RECEIVE_BUFFER_LENGTH 300 //define maximum lehgth of receive from remote once

/**
 * @brief 当前遥操作信号来源编号
 */
typedef enum
{ERROR_RECEIVE=0, DT7}RemoteSourceEnum;

/**
 * @brief 由于遥操作数据可能来源于不同遥控器或自定义控制器，为了robotcontrol中拿到的信息能统一，
 *		  将不同遥控器的键位信息归化到统一的键位信息结构体中，便于读取
 */
typedef struct
{
	uint8_t remote_source;
	__packed struct
	{
		unsigned switch_L1   : 2;
		unsigned switch_R1   : 2;
		unsigned reserved 	 : 4;
	}Switch;
	
	__packed struct{
		unsigned level_key_W : 1;
		unsigned level_key_S : 1;
		unsigned level_key_A : 1;
		unsigned level_key_D : 1;
		unsigned level_key_SHIFT : 1;
		unsigned level_key_CTRL  : 1;
		unsigned level_key_Q : 1;
		unsigned level_key_E : 1;
		
		unsigned level_key_R : 1;
		unsigned level_key_F : 1;
		unsigned level_key_G : 1;
		unsigned level_key_Z : 1;	
		unsigned level_key_X : 1;
		unsigned level_key_C : 1;
		unsigned level_key_V : 1;
		unsigned level_key_B : 1;
	}PCKeyBoard;
	
	struct
	{
		uint8_t mouse_left;
		uint8_t mouse_right;
		int16_t mouse_speed_x;
		int16_t mouse_speed_y;
		int16_t mouse_speed_z;
	}PCMouse;
	struct
	{
		float ch0, ch1, ch2, ch3, ch4;
	}RelativeCH;
}NormRemoteCmd;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/**
 * @brief DJI电机接收结构体
 */
typedef struct
{
	uint16_t 	frame_counter;
	int16_t 	torque_current_real;
	int16_t 	mechanical_angle;
	int16_t		mechanical_speed_rpm;
	uint8_t 	motor_temperature_d;	
}DJIGMotorRec;

/// @brief 瓴控电机接收结构体
typedef struct 
{
	int8_t temperature;
	int16_t iq;
	float speed_rps;
	uint16_t encoder;
	uint8_t frame_counter;
}LKMotorRec;

typedef struct
{
	uint16_t frame_counter;
	float compensated_power;
	float cap_volt;
	float power_limit;
	float real_power;
}SuperCapacity;
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define HEAT_MAX 5000-1
#define HEAT_MIN 500
#define HEAT_MID 3500
#define IMU_TARGET_TEMPERATURE 40
 
#define ONBOARD_EKF_SOLVE //开启板载imu解算

/**
 * @brief 姿态记录结构体
 */
typedef struct
{
	/*欧拉角姿态，单位为degree*/
	float pitch_d;
	float yaw_d;
	float roll_d;
	
	/*绕xyz三轴的角速度，单位为rad/s*/
	float pitch_radps;
	float roll_radps;
	float yaw_radps;
}Pose;
void PeripheralRecEnable(void);
void RemoteRecRestart(void);
#endif

